package games.flvPlayer.data
{
	import core.Global;
	
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.EventDispatcher;
	
	import utils.CountManager;
	
	public class ContrlShowInfo extends EventDispatcher
	{
		private var m_target:Sprite;
		private var m_isShow:Boolean;
		private var m_cm:CountManager;
		
		private var m_width:Number;
		private var m_height:Number;
		private var m_x:Number;
		private var m_y:Number;
		
		public function ContrlShowInfo(mc:Sprite)
		{
			m_target = mc;
			m_isShow = false;
		}
		
		public function resize(w:Number,h:Number):void
		{
			if(m_isShow)
			{
				m_x = (w - m_target.width) / 2;
				m_y = (h - m_target.height);
				
				if(!m_cm)
				{
					m_cm = new CountManager(null);
					m_cm.interval = 3000;
					m_cm.total = 1;
					//m_cm.addEventListener(Event.CHANGE,onChangeCount);
					m_cm.addEventListener(Event.COMPLETE,onCompleteCount);
					Global.addAction(m_cm);					
				}
				else
				{
					m_cm.start = true;
				}
				
			}
			
			dispatchEvent(new Event(Event.CHANGE));
			
		}
		
		public function get x():Number
		{
			return m_x;
		}
		
		public function get y():Number
		{
			return m_y;
		}
		
		public function set isShow(b:Boolean):void
		{
			m_isShow = b;
			dispatchEvent(new Event(Event.CHANGE));
		}
		
		public function get isShow():Boolean
		{
			return m_isShow;
		}
		
		private function onChangeCount(e:Event):void
		{
			
			
		}
		private function onCompleteCount(e:Event):void
		{
			trace("complete");
			isShow = false;
			m_cm = null;
		}
	}
}